//
//  HomepageController.m
//  迷笛
//
//  Created by . on 2018/9/5.
//  Copyright © 2018年 🍃🌺🌺🍃. All rights reserved.
//

#import "MIDIHomepageController.h"
#import "MIDIHomepaCollectionViewCell.h"
#import "MIDINewticketController.h"
#import "MIDIHotRecommendedController.h"
#import "MIDIbroadcastController.h"
#import "MIDIhomemodel.h"

#import "MIDIrecommendCell.h"
#import "MIDIticketingCell.h"

#import "GPBannerView.h"
@interface MIDIHomepageController ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate>
@property(nonatomic,strong)UITableView * HomeTable;
@property(nonatomic,strong)UICollectionView * HomeColletion;
@property(nonatomic,strong)UIView * headvew;
@property(nonatomic,strong)NSArray  * arrimage;
@property(nonatomic,strong)NSArray * arr;

@property ( nonatomic , copy ) NSMutableArray *slideArr;
@property ( nonatomic , copy ) NSMutableArray *ticketArr;
@property ( nonatomic , copy ) NSMutableArray *activityArr;
@property ( nonatomic , copy ) NSMutableArray *musicArr;
@property(nonatomic,strong)UICollectionView *collect;
@property(nonatomic,strong)UIScrollView * scroll;
@property(nonatomic,copy)NSArray * hotArr;

@property (nonatomic, weak) GPBannerView *bannerView;

@property(nonatomic,strong)UIView * ticketView;
@property(nonatomic,strong)UIImageView * ticketImage;
@property(nonatomic,strong)UILabel * titleText;
@property(nonatomic,strong)UILabel * tickerLocation;
@property(nonatomic,strong)UILabel * activityTime;
@property(nonatomic,strong)UILabel * rmb;

@property(nonatomic,copy)NSDictionary * hottitleleftDic;
@property(nonatomic,copy)NSDictionary * hottitletopDic;
@property(nonatomic,copy)NSDictionary * hottitleupDic;

@property(nonatomic,strong)NSString * homeindex;

@end

@implementation MIDIHomepageController

- (void)viewDidLoad {
    [super viewDidLoad];
//   黑色字变为白色
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

    self.view.backgroundColor =[UIColor colorWithHexString:@"#171717"];
    self.tabBarController.tabBar.tintColor = [UIColor colorWithHexString:@"#FF005D"];
    
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD showWithStatus:@"加载中"];
    [SVProgressHUD dismissWithDelay:1.0];
    
    [self inAFN];
    
    _ticketArr = [NSMutableArray array];
    _activityArr = [NSMutableArray array];
    _musicArr = [NSMutableArray array];


    
    [self HomeUI];
    
    
    [_HomeTable registerClass:[UITableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"header"];

//    [self inAFN];
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
    if (section == 0)
    {
        return _ticketArr.count;
    }
    if (section == 1)
    {
        return _activityArr.count;
    }
    if (section ==2)
    {
        return 1;
    }
    return 0;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //取消选中效果
    [_HomeTable deselectRowAtIndexPath:indexPath animated:NO];

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    MIDIrecommendCell  * cell =[tableView dequeueReusableCellWithIdentifier:@"mycell"];
    if (cell == nil)
    {
        static NSString * cellID = @"cell";

        cell =[[MIDIrecommendCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
        cell.backgroundColor =[UIColor colorWithHexString:@"#171717"];
//        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.selectedBackgroundView.backgroundColor = [UIColor colorWithHexString:@"#171717"];//选中后变换，色彩的变换

    }
//    分区一
    if (indexPath.section == 0)
    {
        MIDIhomemodel * mm1 = _ticketArr[indexPath.row];
        
        _hotArr=@[@"1",@"2",@"3"];
        _scroll=[[UIScrollView alloc] initWithFrame:CGRectMake(5, 10, self.view.frame.size.width, kDevice_Is_iPhoneX?HeighX(118):HeightScale(118))];
   

        
        //    隐藏滑动条
        [_scroll setShowsHorizontalScrollIndicator:NO];
        _scroll.backgroundColor =[UIColor colorWithHexString:@"#171717"];
        //   取消反弹
        _scroll.bounces = NO;
        _scroll.scrollEnabled = YES;
        _scroll.pagingEnabled=YES;

        [cell addSubview:_scroll];

        //滚动视图的内容的大小
        NSInteger pageNumber=_ticketArr.count;
        _scroll.contentSize=CGSizeMake(self.view.frame.size.width*pageNumber, kDevice_Is_iPhoneX?HeighX(118):HeightScale(118));

        for (int i=0; i<pageNumber; i++)
        {
            UIImageView *image1=[[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width*i, 0, self.view.frame.size.width, kDevice_Is_iPhoneX?HeighX(118):HeightScale(118))];
            //        UIImageView *image1=[[UIImageView alloc]init];
            image1.image=[UIImage imageNamed:_hotArr[i]];
        
            [_scroll addSubview:image1];
            _ticketView = [[UIView alloc]init];
            _ticketView.backgroundColor =[UIColor colorWithHexString:@"#1B212F"];
            [image1 addSubview:self.ticketView];
            [self.ticketView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(self.scroll);
                make.left.mas_offset(WidthScale(10));
                make.width.mas_offset(WidthScale(347));
                make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(118):HeightScale(118));
            }];
            
            
            
            _ticketImage =[[UIImageView alloc]init];
            _ticketImage.image =[UIImage imageNamed:@"IMG_0195.jpg"];
            [image1 addSubview:_ticketImage];
            [self.ticketImage mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(self.scroll);
                make.left.mas_offset(WidthScale(20));
                make.width.mas_offset(WidthScale(78));
                make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(99):HeightScale(99));
            }];
            _titleText = [[UILabel alloc]init];
            _titleText.text = @"北部湾（钦州）迷笛音乐节";
            _titleText.textColor =[UIColor colorWithHexString:@"#FFFFFF"];
            _titleText.font =[UIFont systemFontOfSize:WidthScale(16)];
            [image1 addSubview:self.titleText];
            [self.titleText mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.ticketImage);
                make.left.equalTo(self.ticketImage.mas_right).mas_offset(WidthScale(20));
                make.width.mas_offset(WidthScale(200));
                make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(20):HeightScale(20));
            }];
            _tickerLocation =[[UILabel alloc]init];
            _tickerLocation.text =[NSString stringWithFormat:@"地址:%@",mm1.location];
            _tickerLocation.textColor =[UIColor colorWithHexString:@"#FFFFFF"];
            _tickerLocation.font =[UIFont systemFontOfSize:WidthScale(14)];
            [image1 addSubview:self.tickerLocation];
            [self.tickerLocation mas_makeConstraints:^(MASConstraintMaker *make)
            {
                make.top.equalTo(self.titleText.mas_bottom).mas_offset(WidthScale(10));
                make.left.equalTo(self.titleText);
                make.width.mas_offset(WidthScale(200));
                make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(14):HeightScale(14));
            }];
            _activityTime =[[UILabel alloc]init];
            _activityTime.text = [NSString stringWithFormat:@"时间:%@",mm1.name];
            _activityTime.textColor =[UIColor colorWithHexString:@"#FFFFFF"];
            _activityTime.font =[UIFont systemFontOfSize:WidthScale(14)];
            [image1 addSubview:self.activityTime];
            [self.activityTime mas_makeConstraints:^(MASConstraintMaker *make)
             {
                 make.top.equalTo(self.tickerLocation.mas_bottom).mas_offset(WidthScale(10));
                 make.left.equalTo(self.titleText);
                 make.width.mas_offset(WidthScale(200));
                 make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(14):HeightScale(14));
             }];
            _rmb =[[UILabel alloc]init];
            _rmb.text = @"票价：￥100—￥1800";
            _rmb.textColor =[UIColor colorWithHexString:@"#FF005D"];
            _rmb.font =[UIFont systemFontOfSize:WidthScale(14)];
            [image1 addSubview:self.rmb];
            [self.rmb mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.activityTime.mas_bottom).mas_offset(WidthScale(10));
                make.left.equalTo(self.titleText);
                make.width.mas_offset(WidthScale(200));
                make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(14):HeightScale(14));
            }];
        }
        
    }
//    分区二
    else if (indexPath.section == 1)
    {
        MIDIticketingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myclel"];
        if (cell == nil)
        {
            static NSString * cellID = @"cell";
            cell =[[MIDIticketingCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
            cell.backgroundColor =[UIColor colorWithHexString:@"#171717"];
        }

        MIDIhomemodelactivity * mm2 = _activityArr[indexPath.row];
//        cell.hutiamge1.image = ;
//        cell.hutiamge1.image = [UIImage imageNamed:@"IMG_0195.jpg"];

       
        cell.hutback1.image =[UIImage imageNamed:@"home-touming"];

        [cell.hutiamge1 sd_setImageWithURL:[NSURL URLWithString:mm2.activityCover] placeholderImage:nil];

//        活动标题
        cell.tile1.text = mm2.activityName1;

//        cell.hutiamge2.image = [UIImage imageNamed:@"IMG_0195.jpg"];
        cell.hutback2.image =[UIImage imageNamed:@"home-touming"];
        [cell.hutiamge2 sd_setImageWithURL:[NSURL URLWithString:mm2.activityCover1] placeholderImage:nil];

//        活动标题
        cell.tile2.text = mm2.activityName2;

//        cell.hutiamge3.image = [UIImage imageNamed:@"IMG_0195.jpg"];
        cell.hutback3.image =[UIImage imageNamed:@"home-touming"];
        [cell.hutiamge3 sd_setImageWithURL:[NSURL URLWithString:mm2.activityCover2] placeholderImage:nil];

//        活动标题
        cell.tile3.text = mm2.activityName3;
    
      
        return cell;
        
    }
    else if (indexPath.section ==2)
    {
        // 创建流布局对象 (保存设定的样式规则)
        UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
        // 设定单元格的大小
        flow.itemSize = CGSizeMake(WidthScale(90), kDevice_Is_iPhoneX?HeighX(140):HeightScale(100));
        // 设定滚动方向
        flow.scrollDirection = UICollectionViewScrollDirectionVertical;
        // 最小列间距
        flow.minimumInteritemSpacing = WidthScale(5);
        // 最小行间距
        flow.minimumLineSpacing = WidthScale(45);
        // 设定分区的边距
        flow.sectionInset = UIEdgeInsetsMake(WidthScale(5), WidthScale(25), WidthScale(5), HeightScale(25));

        // 创建网格对象，用流布局对象进行初始化
       _collect = [[UICollectionView alloc] initWithFrame:CGRectMake(0, WidthScale(5), self.view.frame.size.width, kDevice_Is_iPhoneX?HeighX(350):HeightScale(350)) collectionViewLayout:flow];

        // 设定代理关系
        _collect.dataSource = self;
        _collect.delegate = self;

        _collect.pagingEnabled = YES;
        _collect.scrollEnabled = NO;
        _collect.backgroundColor = [UIColor colorWithHexString:@"#171717"];
        // 将网格加入到视图上显示
        [cell.contentView addSubview:_collect];

        // 为网格注册单元格类
        [_collect registerClass:[MIDIHomepaCollectionViewCell class] forCellWithReuseIdentifier:@"Homepacollectioncell"];
        
    }
    return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UITableViewHeaderFooterView *headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"header"];
    
    UIImageView * SG = [[UIImageView alloc]init];
    SG.image = [UIImage imageNamed:@"圆角矩形 1"];
    [headerView addSubview:SG];
    [SG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(headerView);
        make.left.mas_equalTo(WidthScale(25));
        make.width.mas_equalTo(WidthScale(2));
        make.height.mas_equalTo(kDevice_Is_iPhoneX?HeighX(12):HeightScale(12));
    }];
        if (section == 0)
    {
        UIImageView * SGiamge = [[UIImageView alloc]init];
        SGiamge.image = [UIImage imageNamed:@"最新票务"];
        [headerView addSubview:SGiamge];
        [SGiamge mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(headerView);
            make.left.equalTo(SG.mas_right).offset(WidthScale(20));
            make.width.mas_equalTo(WidthScale(61));
            make.height.mas_equalTo(kDevice_Is_iPhoneX?HeighX(17):HeightScale(17));
        }];
        
        UIButton * more =[[UIButton alloc]init];
        [more setTitle:@"更多" forState:UIControlStateNormal];
        [more setTitleColor:[UIColor colorWithHexString:@"#00DFFF"] forState:UIControlStateNormal];
        more.titleLabel.font = [UIFont systemFontOfSize: 13.0];
        [more addTarget:self action:@selector(moreBtn1:) forControlEvents:UIControlEventTouchUpInside];
        [headerView addSubview:more];
        [more mas_makeConstraints:^(MASConstraintMaker * make) {
            make.centerY.mas_equalTo(headerView);
            make.left.equalTo(headerView.mas_right).offset(WidthScale(-50));
            make.width.mas_equalTo(WidthScale(40));
            make.height.mas_equalTo(kDevice_Is_iPhoneX?HeighX(30):HeightScale(30));
        }];
    }
    if (section == 1)
    {
        UIImageView * SGiamge = [[UIImageView alloc]init];
        SGiamge.image = [UIImage imageNamed:@"热门推荐"];
        [headerView addSubview:SGiamge];
        [SGiamge mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(headerView);
            make.left.equalTo(SG.mas_right).offset(WidthScale(20));
            make.width.mas_equalTo(WidthScale(61));
            make.height.mas_equalTo(kDevice_Is_iPhoneX?HeighX(17):HeightScale(17));
        }];
        
        UIButton * more =[[UIButton alloc]init];
        [more setTitle:@"更多" forState:UIControlStateNormal];
        [more setTitleColor:[UIColor colorWithHexString:@"#00DFFF"] forState:UIControlStateNormal];
        more.titleLabel.font = [UIFont systemFontOfSize: 13.0];
        [more addTarget:self action:@selector(moreBtn:) forControlEvents:UIControlEventTouchUpInside];
        [headerView addSubview:more];
        [more mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(headerView);
            make.left.equalTo(headerView.mas_right).offset(WidthScale(-50));
            make.width.mas_equalTo(WidthScale(40));
            make.height.mas_equalTo(kDevice_Is_iPhoneX?HeighX(30):HeightScale(30));
        }];
    }
    if (section == 2)
    {
        UIImageView * SGiamge = [[UIImageView alloc]init];
        SGiamge.image = [UIImage imageNamed:@"音乐推荐"];
        [headerView addSubview:SGiamge];
        [SGiamge mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(headerView);
            make.left.equalTo(SG.mas_right).offset(WidthScale(20));
            make.width.mas_equalTo(WidthScale(61));
            make.height.mas_equalTo(kDevice_Is_iPhoneX?HeighX(17):HeightScale(17));
        }];
    }

    return headerView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return WidthScale(30);
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}

- ( UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
{
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        return kDevice_Is_iPhoneX?HeighX(118):HeightScale(118);
    }
    if (indexPath.section == 1)
    {
        return kDevice_Is_iPhoneX?HeighX(200):HeightScale(185);
    }
    if (indexPath.section == 2)
    {
        return kDevice_Is_iPhoneX?HeighX(380):HeightScale(320);
    }
    return kDevice_Is_iPhoneX?HeighX(0):HeightScale(0);
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
  
    return 2;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _musicArr.count;
}

// 网格单元格内容
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    MIDIHomepaCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Homepacollectioncell" forIndexPath:indexPath];
    if (indexPath.section == 0)
    {
        
            MIDIhomemodelmusic * mm3 = _musicArr[indexPath.row];
            // 设置显示数据
            cell.backview.backgroundColor =[UIColor whiteColor];
            cell.songimage.image = [UIImage imageNamed:@"timg (1)"];
        

        
            cell.song.text = mm3.name2;
            cell.singer.text = mm3.singer;
//        NSString *image = mm3.cover;
//        NSString *mms = [NSString stringWithFormat:@"%@", mm3.cover];
//        cell.mainimage.image =[UIImage imageNamed:mms];
//        cell.mainimage.image =[UIImage imageNamed:@"IMG_0195.jpg"];
//        [cell.mainimage sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:nil];
        
            [cell.mainimage sd_setImageWithURL:[NSURL URLWithString:mm3.cover] placeholderImage:nil];
       
//        [cell.mainimage sd_setImageWithURL:image];
//            cell.song.text = @"泡沫";
//            cell.singer.text = @"邓紫棋";
        }
    return cell;
}
-(void)inAFN
{
    NSString * homestr = @"index";
    _homeindex = [NSString stringWithFormat:@"%@%@",MIDIApiRoot,homestr];

    [EdHttp get:_homeindex params:nil progress:^(id downloadProgress)
     {
      
         NSLog(@"1111");
     }
        success:^(id responseObject)
     {
//         NSData *jsonData = [NSJSONSerialization dataWithJSONObject:responseObject options:NSJSONWritingPrettyPrinted error:nil];
//         // NSData转为NSString
//         NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//         NSLog(@"转译%@", jsonStr);

         
         NSMutableDictionary *dic = responseObject[@"data"];
         NSLog(@"%@",responseObject);
         
         self.arrimage = dic[@"slide"];
         for (NSDictionary *dic2 in self.arrimage)
         {
             NSString * path;
      
             if (![dic2[@"path"] isKindOfClass:[NSNull class]])
             {
                 path = dic2[@"path"];
             }
             else
             {
                 path = @"";
             }
             MIDIhomemodelslide * slidemm = [MIDIhomemodelslide new];
             slidemm.slide = path;
        
             
             [self->_slideArr addObject:slidemm];
         }
         
         
         
         
         NSArray *arr = dic[@"ticket"];
         for (NSDictionary *dic2 in arr)
         {
             NSString * name;
             NSString * location;
             NSString * cover;
             if (![dic2[@"name"] isKindOfClass:[NSNull class]])
             {
                 name = dic2[@"name"];
             }
             else
             {
                 name = @"";
             }
             if (![dic2[@"cover"] isKindOfClass:[NSNull class]])
             {
                 cover = dic2[@"cover"];
             }
             else
             {
                 cover = @"";
             }
             if (![dic2[@"location"] isKindOfClass:[NSNull class]])
             {
                location  = dic2[@"location"];
             }
             else
             {
                 location = @"";
             }
            
             MIDIhomemodel * mm = [MIDIhomemodel new];
             mm.name = name;
             mm.location = location;
             mm.cover = cover;

             [self->_ticketArr addObject:mm];
         }
         NSArray *arr3 = dic[@"activity"];
             NSString * activityName1;
             NSString * activityName2;
             NSString * activityName3;
            NSString * activityCover;
            NSString * activityCover1;
            NSString * activityCover2;

             //遍历数组list里的内容
           
             for (int i = 0; i<[arr3 count]; i++)
             {
                 //按数组中的索引取出对应的字典
                 self.hottitleleftDic = [arr3 objectAtIndex:i];
                 self.hottitletopDic =[arr3 objectAtIndex:i=1];
                 self.hottitleupDic =[arr3 objectAtIndex:i=2];

        //  之前遍历的数组是不对里面没有数据，现在里面有了 用这个取一下。
        //  NSLog(@"name内容为--》%@", _listDic[@"name"]);
                 activityName1 = self.hottitleleftDic[@"name"];
                 activityCover = self.hottitleleftDic[@"cover"];
                 activityName2 = self.hottitletopDic[@"name"];
                 activityCover1 = self.hottitletopDic[@"cover"];

                 activityName3 = self.hottitleupDic[@"name"];
                 activityCover2 = self.hottitleupDic[@"cover"];


                 MIDIhomemodelactivity * mmact = [MIDIhomemodelactivity new];
                 mmact.activityName1 = activityName1;

                 mmact.activityName2 = activityName2;
                 mmact.activityName3 = activityName3;
                 mmact.activityCover = activityCover;
                 mmact.activityCover1 = activityCover1;
                 mmact.activityCover2 = activityCover2;

                 NSLog(@"activity网络请求%@",activityName1);
                 [self->_activityArr addObject:mmact];
                 
             }

         NSArray *arr4 = dic[@"music"];

         for (NSDictionary *dic4 in arr4)
         {
             NSString * name2;
             NSString * singer;
             NSString * coveR;
             if (![dic4[@"name"] isKindOfClass:[NSNull class]])
             {
                 name2 = dic4[@"name"];
             }
             else
             {
                 name2 = @"";
             }
             if (![dic4[@"singer"] isKindOfClass:[NSNull class]])
             {
                 singer = dic4[@"singer"];
             }
             else
             {
                 singer = @"";
             }
             if (![dic4[@"cover"] isKindOfClass:[NSNull class]])
             {
                 coveR = dic4[@"cover"];
             }
             else
             {
                 coveR = @"";
             }
             MIDIhomemodelmusic * mmact = [MIDIhomemodelmusic new];
             mmact.name2 = name2;
             mmact.singer = singer;
             mmact.cover = coveR;
             NSLog(@"music网络请求%@",mmact.name2);
             NSLog(@"music网络请求%@",mmact.cover);

             [self->_musicArr addObject:mmact];
         }
        
            dispatch_async(dispatch_get_main_queue(), ^{
             [self->_HomeTable reloadData];
             
         });
         
         NSLog(@"==========%@",responseObject);
     }
        failure:^(NSError *error)
     {
         NSLog(@"失败");
     }];
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
{
    MIDIbroadcastController * broad =[[MIDIbroadcastController alloc]init];
    [self.navigationController pushViewController:broad animated:YES];
}

//视图将要出现时（导航颜色字体颜色）
- (void)viewWillAppear:(BOOL)animated
{
//    self.tabBarController.tabBar.hidden = NO;
//    self.navigationController.navigationBar.translucent = YES;//Bar的模糊效果，默认为YES
//
//    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#171717"];
//    self.title = @"迷笛音乐";
//  [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FFFFFF"],NSFontAttributeName : [UIFont fontWithName:@"Helvetica-Bold" size:WidthScale(17)]}];
//    //    去掉导航黑线
//    UIImage *img = [UIImage imageNamed:@""];
//    [self.navigationController.navigationBar setBackgroundImage:img  forBarMetrics:UIBarMetricsDefault];
//    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.navigationController.navigationBar.translucent = NO;//Bar的模糊效果，默认为YES
    
    self.tabBarController.tabBar.hidden = NO;
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#171717"];
//    self.title = @"迷笛音乐";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FFFFFF"],NSFontAttributeName : [UIFont fontWithName:@"Helvetica-Bold" size:WidthScale(17)]}];
    //    去掉导航黑线
    UIImage *img = [UIImage imageNamed:@""];
    [self.navigationController.navigationBar setBackgroundImage:img  forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    
    
    
}
-(void)HomeUI
{
    [self.view addSubview:self.HomeTable];
    
   
}
-(UITableView *)HomeTable
{
    if (!_HomeTable)
    {
//        _HomeTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, kDevice_Is_iPhoneX?HeighX(self.view.frame.size.height-78):HeightScale(self.view.frame.size.height -70)) style:UITableViewStyleGrouped];
        
//        _HomeTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, kDevice_Is_iPhoneX?HeighX(800):HeightScale(678)) style:UITableViewStyleGrouped];
        _HomeTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height-40) style:UITableViewStyleGrouped];
        
        _HomeTable.dataSource = self;
        _HomeTable.delegate = self;
        _HomeTable.tableHeaderView = self.headvew;
        _HomeTable.backgroundColor = [UIColor colorWithHexString:@"#171717"];
        _HomeTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self.HomeTable reloadData];
    }
    return _HomeTable;
}
-(UIView *)headvew
{
    if (!_headvew)
    {
        _headvew = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, kDevice_Is_iPhoneX?HeighX(228):HeightScale(228))];
        _headvew.backgroundColor =[UIColor whiteColor];
        [self setupUI];
        [self setupConstraints];
    }
    return _headvew;
}

- (void)setupUI
{
//    MIDIhomemodel * mm1 = self.arrimage;

    NSArray *dataSource = @[@"IMG_0195.jpg", @"IMG_0195.jpg", @"IMG_0195.jpg"];

    GPBannerView *bannerView = [GPBannerView bannerViewWithFrame:CGRectZero dataSource:dataSource];
    bannerView.time = 3;
    [_headvew addSubview:bannerView];
    self.bannerView = bannerView;
}


#pragma mark - Constraints

- (void)setupConstraints {
    
    [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.headvew);
        make.centerY.equalTo(self.headvew);
        make.width.mas_offset(self.view.frame.size.width);
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(228):HeightScale(228));
    }];
}

-(void)moreBtn:(UIButton * )sender
{
    MIDIHotRecommendedController * HotRecommended =[[MIDIHotRecommendedController alloc]init];
    [self.navigationController pushViewController:HotRecommended animated:YES];
}
-(void)moreBtn1:(UIButton * )sender
{
    MIDINewticketController * newtick = [[MIDINewticketController alloc]init];
    [self.navigationController pushViewController:newtick animated:YES];
}

@end
